<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('延期申请-未审')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            工单编号：<input type="text" name="workFormNo"/>
                        </li>
                        <li>
                            申请单位：<input type="text" name="adeptName"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm " id="toolbar" role="group">
            <a class="btn btn-primary multiple disabled" onclick="btnChkClick()">
                <i class="fa fa-edit"></i> 处理
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "system/mInterior";
    $(function () {
        var options = {
            url: prefix + "/cmnFile/tDeferUntriedJson",
            sortName: "pkId",
            sortOrder: "desc",
            removeUrl: prefix + "/cmnFile/removetwfDeferJson",
            uniqueId: "pkId",
            modalName: "延期申请",
            fixedColumns: true,
            fixedNumber: 2,
            fixedRightNumber: 1,
            columns: [
                {field: 'ck', checkbox: true, title: '&nbsp;'},
                {field: 'pkId', title: 'pkid', hidden: true, visible: false},
                {field: 'sendID', title: 'SendID', hidden: true, visible: false},
                {field: 'wfId', title: 'WfId', hidden: true, visible: false},
                {field: 'workFormNo', title: '工单编号', align: 'center', sortable: true},
                {field: 'adeptName', title: '申请单位', align: 'center', sortable: true},
                {field: 'limitTime', title: '原要求时限', align: 'center', sortable: true},
                {field: 'delay', title: '延期至', align: 'center', sortable: true},
                {field: 'delayRn', title: '延期理由',  align: 'center'},
                {
                    field: 'deferState', title: '状态', hidden: true, formatter: function (value, row, index) {
                        return fmtDerferState(value, row, index);
                    }
                },
                {field:'deferCount',title:'已延期次数',align:'center',halign:'center'},
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="btnChkClick(\'' + row.pkId + '\',\'处理延期申请\')"><i class="fa fa-edit"></i>处理</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    //审核延期 ？ 单选 进入审核延期页面 ：多选 进入批量审核延期
    function btnChkClick(id){
        let row = $("#bootstrap-table").bootstrapTable('getSelections');
        if(row.length > 1){//批量延期
            var ids = "";
            $.each(row,function(index,value){
                ids += row[index].pkId + ",";
            })
            ids = ids.substr(0,ids.length - 1);
            var url = prefix + "/cmnFile/tDeferBatchCheck?ids="+ids;
            var title = '批量审核延期';
            var width = "500px";
            var height = "500px";
            var options = {
                url: url,
                title: title,
                width: width,
                height: height,
                btnArr: []
            }
            winDialog(options);
        }else {//延期列表
            if (!id) {
                id = row[0].pkId;
            }
            var url = prefix + "/cmnFile/twfDeferList/"+id;
            $.modal.openTab('延期申请情况',url);
        }

    }
</script>
</body>
</html>